package club.ruanx.movie.advice;

import club.ruanx.acl.common.exception.UserException;
import club.ruanx.bean.ResultVO;
import club.ruanx.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理类
 *
 * @author 阮胜
 * @date 2018/9/22 13:26
 */
@ControllerAdvice
@Slf4j
public class GlobalDefaultSysExceptionHandler {

    @ExceptionHandler({BaseException.class, UserException.class})
    @ResponseBody
    public ResultVO defaultSysExceptionHandler(Exception e) {
        return new ResultVO(e.getMessage(), false, null);
    }
}
